﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for ProductDAL
/// </summary>
public class ProductDAL
{
    DatabaseAccess dba = new DatabaseAccess();

    public ProductDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public DataTable GetAllProduct()
    {
        return dba.executeSelect("proc_GetProduct");
    }

    public DataTable GetProductByID(int id)
    {
        SqlParameter[] param = new SqlParameter[1];
        param[0] = new SqlParameter("@pd_id", SqlDbType.Int);
        param[0].Value = id;
        return dba.executeSelect("proc_GetProductByID",param);
    }

    public DataTable GetProductByCategory(int cat_id)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@cat_id",SqlDbType.Int);
        paramList[0].Value = cat_id;
        return dba.executeSelect("proc_getProductByCategoryID",paramList);
    }
    public DataTable searchProductByName(String pd_name)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@pd_name",SqlDbType.NVarChar,50);
        paramList[0].Value = pd_name;
        return dba.executeSelect("proc_searchProductByName",paramList);
    }
    public DataTable searchProductByPrice(decimal pd_price)
    {
        SqlParameter[] paramList = new SqlParameter[1];      
        paramList[0] = new SqlParameter("@pd_price",SqlDbType.Money);
        paramList[0].Value = pd_price;
        return dba.executeSelect("proc_GetProductByPrice",paramList);
    }
}
